package comgame.entities;

import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.EntityFactory;
import com.almasb.fxgl.entity.SpawnData;
import com.almasb.fxgl.entity.Spawns;
import comgame.components.EquipmentComponent.*;
import comgame.entities.EquipmentEnum.*;

public class EquipmentFactory implements EntityFactory {

    // 私有方法：创建头盔
    private Entity createHelmet(SpawnData data, HelmetType type) {
        return FXGL.entityBuilder(data)
                .type(type)
                .with(new HelmetComponent(type))
                .build();
    }

    // 私有方法：创建胸甲
    private Entity createChestplate(SpawnData data, ChestplateType type) {
        return FXGL.entityBuilder(data)
                .type(type)
                .with(new ChestplateComponent(type))
                .build();
    }

    // 私有方法：创建护腿
    private Entity createLegging(SpawnData data, LeggingType type) {
        return FXGL.entityBuilder(data)
                .type(type)
                .with(new LeggingComponent(type))
                .build();
    }

    // 私有方法：创建靴子
    private Entity createBoot(SpawnData data, BootType type) {
        return FXGL.entityBuilder(data)
                .type(type)
                .with(new BootComponent(type))
                .build();
    }

    // 私有方法：创建剑
    private Entity createSword(SpawnData data, SwordType type) {
        return FXGL.entityBuilder(data)
                .type(type)
                .with(new SwordComponent(type))
                .build();
    }

    // 创建头盔实体
    @Spawns("HELMET_1")
    public Entity createHelmet1(SpawnData data) {
        return createHelmet(data, HelmetType.HELMET_1);
    }
    @Spawns("HELMET_2")
    public Entity createHelmet2(SpawnData data) {
        return createHelmet(data, HelmetType.HELMET_2);
    }
    @Spawns("HELMET_3")
    public Entity createHelmet3(SpawnData data) {
        return createHelmet(data, HelmetType.HELMET_3);
    }
    @Spawns("HELMET_4")
    public Entity createHelmet4(SpawnData data) {
        return createHelmet(data, HelmetType.HELMET_4);
    }

    // 新增头盔
    @Spawns("HELMET_GHOST")
    public Entity createHelmetGhost(SpawnData data) {
        return createHelmet(data, HelmetType.HELMET_GHOST);
    }
    @Spawns("HELMET_SPACEKING")
    public Entity createHelmetSpaceKing(SpawnData data) {
        return createHelmet(data, HelmetType.HELMET_SPACEKING);
    }

    // 创建胸甲实体
    @Spawns("CHESTPLATE_1")
    public Entity createChestplate1(SpawnData data) {
        return createChestplate(data, ChestplateType.CHESTPLATE_1);
    }
    @Spawns("CHESTPLATE_2")
    public Entity createChestplate2(SpawnData data) {
        return createChestplate(data, ChestplateType.CHESTPLATE_2);
    }
    @Spawns("CHESTPLATE_3")
    public Entity createChestplate3(SpawnData data) {
        return createChestplate(data, ChestplateType.CHESTPLATE_3);
    }
    @Spawns("CHESTPLATE_4")
    public Entity createChestplate4(SpawnData data) {
        return createChestplate(data, ChestplateType.CHESTPLATE_4);
    }

    // 新增胸甲
    @Spawns("CHESTPLATE_GHOST")
    public Entity createChestplateGhost(SpawnData data) {
        return createChestplate(data, ChestplateType.CHESTPLATE_GHOST);
    }
    @Spawns("CHESTPLATE_SPACEKING")
    public Entity createChestplateSpaceKing(SpawnData data) {
        return createChestplate(data, ChestplateType.CHESTPLATE_SPACEKING);
    }
    @Spawns("CHESTPLATE_FESTIVE_WINGS")
    public Entity createChestplateFestiveWings(SpawnData data) {
        return createChestplate(data, ChestplateType.CHESTPLATE_FESTIVE_WINGS);
    }
    // 创建护腿实体
    @Spawns("LEGGING_1")
    public Entity createLegging1(SpawnData data) {
        return createLegging(data, LeggingType.LEGGING_1);
    }
    @Spawns("LEGGING_2")
    public Entity createLegging2(SpawnData data) {
        return createLegging(data, LeggingType.LEGGING_2);
    }
    @Spawns("LEGGING_3")
    public Entity createLegging3(SpawnData data) {
        return createLegging(data, LeggingType.LEGGING_3);
    }
    @Spawns("LEGGING_4")
    public Entity createLegging4(SpawnData data) {
        return createLegging(data, LeggingType.LEGGING_4);
    }

    // 新增护腿
    @Spawns("LEGGING_GHOST")
    public Entity createLeggingGhost(SpawnData data) {
        return createLegging(data, LeggingType.LEGGING_GHOST);
    }
    @Spawns("LEGGING_SPACEKING")
    public Entity createLeggingSpaceKing(SpawnData data) {
        return createLegging(data, LeggingType.LEGGING_SPACEKING);
    }

    // 创建靴子实体
    @Spawns("BOOT_1")
    public Entity createBoot1(SpawnData data) {
        return createBoot(data, BootType.BOOT_1);
    }
    @Spawns("BOOT_2")
    public Entity createBoot2(SpawnData data) {
        return createBoot(data, BootType.BOOT_2);
    }
    @Spawns("BOOT_3")
    public Entity createBoot3(SpawnData data) {
        return createBoot(data, BootType.BOOT_3);
    }
    @Spawns("BOOT_4")
    public Entity createBoot4(SpawnData data) {
        return createBoot(data, BootType.BOOT_4);
    }

    // 新增靴子
    @Spawns("BOOTS_GHOST")
    public Entity createBootsGhost(SpawnData data) {
        return createBoot(data, BootType.BOOTS_GHOST);
    }
    @Spawns("BOOTS_SPACEKING")
    public Entity createBootsSpaceKing(SpawnData data) {
        return createBoot(data, BootType.BOOTS_SPACEKING);
    }

    // 创建剑实体
    @Spawns("SWORD_1")
    public Entity createSword1(SpawnData data) {
        return createSword(data, SwordType.SWORD_1);
    }
    @Spawns("SWORD_2")
    public Entity createSword2(SpawnData data) {
        return createSword(data, SwordType.SWORD_2);
    }
    @Spawns("SWORD_3")
    public Entity createSword3(SpawnData data) {
        return createSword(data, SwordType.SWORD_3);
    }
    @Spawns("SWORD_4")
    public Entity createSword4(SpawnData data) {
        return createSword(data, SwordType.SWORD_4);
    }

    // 新增剑
    @Spawns("SWORD_GHOST")
    public Entity createSwordGhost(SpawnData data) {
        return createSword(data, SwordType.SWORD_GHOST);
    }
    @Spawns("SWORD_PUMPKIN")
    public Entity createSwordPumpkin(SpawnData data) {
        return createSword(data, SwordType.SWORD_PUMPKIN);
    }
    @Spawns("SWORD_TERRAPRISMA")
    public Entity newSwordTerraprisma(SpawnData data) {
        // 生成泰拉棱镜装备，物品名用中文
        Entity sword = createSword(data, SwordType.SWORD_TERRAPRISMA);
        sword.getComponent(comgame.components.EquipmentComponent.SwordComponent.class).setDisplayName("泰拉棱镜");
        return sword;
    }
}